<?php
require 'inc_security.php';
$rqq_reply = array(1=>'Đã trả lời',2=>'Chưa trả lời');
$sql_search = '';
$rqq_reply_s = getValue('rqq_reply','int',"GET",-1);
$rqq_cus_name = getValue('rqq_cus_name','str',"GET",'');

   if($rqq_reply_s == 2) $rqq_reply_s = 0;
   if($rqq_reply_s != -1 )$sql_search .= ' AND rqq_reply = '.$rqq_reply_s;
   if($rqq_cus_name != '') $sql_search .= " AND rqq_cus_name LIKE '%".$rqq_cus_name."%'"; 

$list = new dataGrid('rqq_id',30);
$list->add('rqq_pro_id','Sản phẩm','str',0,0);
$list->add('rqq_code','Mã sản phẩm','string',0,0);
$list->add('rqq_cus_name','Khách hàng','string',1,1);
$list->add('rqq_cus_phone','Số điện thoại','str',0,0);
$list->add('rqq_cus_email','Email','str',0,0);
$list->add('rqq_cus_address','Địa chỉ','str',0,0);
$list->add('rqq_cus_note','Nội dung','str',0,0);
$list->add('rqq_date','Ngày','str',0,1);
$list->add('rqq_reply','Trạng thái','array',1,0);
$list->add('','Delete','delete');
//$list->addSearch('Loại sản phẩm','rqq_cat_type','array',$global_product_category_type);
$db_count = new db_count('SELECT count(*) as count 
                            FROM '.$bg_table.'
                            WHERE 1 '.$sql_search.'
                            ');
$total = $db_count->total;unset($db_count);

$db_listing = new db_query('SELECT * 
                            FROM '.$bg_table.'
                            WHERE 1 '.$sql_search.'
                            ORDER BY '.$list->sqlSort().' rqq_reply ASC, rqq_id DESC
                            '.$list->limit($total));
$total_row = mysql_num_rows($db_listing->result);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=$list->showHeader($total_row)?>
    <?php
    $i = 0; 
    ?>
    <?php while($row = mysql_fetch_assoc($db_listing->result)){
        $i++;
    ?>
        <?=$list->start_tr($i,$row[$id_field])?>
        
        <td class="center">
            <?=pro_str_name($row['rqq_pro_code'])?>
        </td>
        <td><?=$row['rqq_pro_code']?></td>
        <td>
            <?=$row['rqq_cus_name']?>
        </td>
        <td>
            <?=$row['rqq_cus_phone']?>
        </td>
        <td>
            <?=$row['rqq_cus_email']?>
        </td>
        <td>
            <?=$row['rqq_cus_address']?>
        </td>
        <td>
            <?=$row['rqq_cus_note']?>
        </td>
        <td>
            <?=date('H:m:i - d/m/Y',$row['rqq_date'])?>
        </td>
        <?=$list->showCheckbox('rqq_reply',$row['rqq_reply'],$row[$id_field])?>
        <?=$list->showDelete($row[$id_field])?>
        <?=$list->end_tr()?>
    <?}?>
    <?=$list->showFooter()?>
</div>
</body>
</html>